package com.briup.myblog.web.controller;

import com.briup.myblog.bean.basic.BaseUser;
import com.briup.myblog.service.IBaseUserService;
import com.briup.myblog.utils.Result;
import com.briup.myblog.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/auth/user")
public class BaseUserController {
    @Autowired
    private IBaseUserService service;
    @GetMapping("/info")
    public Result findUserByToken(HttpServletRequest request){
        String token = request.getHeader("Authorization");
        BaseUser baseUser = service.currentUserInfo(token);
        return ResultUtil.success(baseUser);
    }
}
